package com.szxy.backend.item.controller;

import com.szxy.backend.item.service.FileUploadService;
import com.szxy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Auther:zwer
 * @Date:2019/9/7 17:12
 * @Description:com.szxy.backend.item.controller
 * @Version:1.0
 **/
@RestController
@RequestMapping("/file")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    /**
     * 图片上传
     * @param file  图片名
     * @return
     */
    @PostMapping("/upload")
    public Result uploadFile(MultipartFile file){
        try{
            return this.fileUploadService.uploadFile(file);
        }catch (Exception e){
            e.printStackTrace();
        }
        return Result.build(500,"error");
    }


}
